package cn.simon.free.tools.utils;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * BigDecimal 精度转换
 *
 * @author simon
 * @date 2020/4/17 17:23
 * @copyright:
 * @modifier
 * @motto a no talent, people who have to study hard
 */
public class BigDecimalUtils {

    private static final BigDecimal DECIMAL = BigDecimal.valueOf(100);
    private static final int SCALE = 2;

    private BigDecimalUtils() {
    }

    public static BigDecimal divide(String fee, BigDecimal decimal, int scale) {
        return new BigDecimal(fee).divide(decimal, scale, RoundingMode.HALF_UP);
    }

    public static BigDecimal divide(String fee) {
        return divide(fee, DECIMAL, SCALE);
    }
}
